﻿using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace IInject.Tests
{
	[TestClass]
	public class ContainerPerformanceTests
	{
		private static IContainer _container;
		private static Stopwatch _stopwatch;
		private TestContext _testContextInstance;

		/// <summary>
		/// Gets or sets the test context which provides
		/// information about and functionality for the current test run.
		/// </summary>
		public TestContext TestContext
		{
			get
			{
				return _testContextInstance;
			}
			set
			{
				_testContextInstance = value;
			}
		}

		[ClassInitialize]
		public static void MyClassInitialize(TestContext cont)
		{
			_stopwatch = new Stopwatch();
			_container = new Container();
			_container.Set<Dependent>();
			//_container.Map<IInjectedProperty>().To<InjectedProperty>().Apply();
			_container.Map<DependencyTest>().Apply();
		}

		[ClassCleanup]
		public static void MyClassCleanup()
		{
			_container.Registry.Clear();
			//Debug.WriteLine(String.Format("Elapsed Time: {0}", _stopwatch.Elapsed));
		}

		[TestMethod]
		public void TestMethod1()
		{
			//_stopwatch.Start();

			//for (int i = 0; i < 1000000; i++)
			//{
			//    //var test = new Dependent();
			//    var test = _container.Get<DependencyTest>();
			//}

			//_stopwatch.Stop();
			//var time = _stopwatch.Elapsed.ToString();
			//Assert.IsNotNull(test);
		}
	}
}
